<style type="text/css">  
    #jkmap{height:700px}    
</style>
<script language="javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=72563ac934ad74df636a9acc3d5b9726&plugin=AMap.ControlBar"></script>
<div id="jkmap"></div>
<script>
Dcat.ready(function () {
    //window.onLoad  = function(){
        var map = new AMap.Map('jkmap', {
           @if($list)
           center:[{{ $list[0]['lng'] }}, {{ $list[0]['lat'] }}],
           @endif()
           zoom:4,
           mapStyle: "amap://styles/darkblue"
        });
        let markerList = [];
        let links = [];
        @if($list)
            @foreach($list as $k => $v)
                var marker_{{ $k }} = new AMap.Marker({
                    @if($v['icon'])
                        icon:"{{ $v['icon'] }}",
                    @endif
                    position: new AMap.LngLat({{ $v['lng'] }}, {{ $v['lat'] }}),
                    title: '{{ $v['name'] }}',
                    label: {
                        content: '{{ $v['name'] }}',
                        direction: 'top'
                    },
                    clickable: true
                });
                markerList.push(marker_{{$k}});
                links.push('{{ $v['url'] }}');
            @endforeach
            map.add(markerList);
        @endif()
        for(let [index,item] of markerList.entries()){
            markerList[index].on('click',function(){
                window.location.href=links[index];
            });
        }
    //}
    //var url = 'https://webapi.amap.com/maps?v=1.4.15&key=72563ac934ad74df636a9acc3d5b9726&callback=onLoad';
    //var jsapi = document.createElement('script');
    //jsapi.charset = 'utf-8';
    //jsapi.src = url;
    //document.head.appendChild(jsapi);
    //console.log('所有JS脚本都加载完了');
});
</script>